/*************************************************************************
	> File Name: thread_test.c
	> Author: luqingliang
	> Mail: 13420685558@163.com
	> Created Time: 2024年02月13日 星期二 22时01分47秒
 ************************************************************************/

#include <stdio.h>
#include <stdlib.h>

#include <string.h>
#include <unistd.h>
#include "thread.h"

void *tmp(void *arg)
{
	int count = 0;
	int *i = (int *)arg;
	while (1)
	{
		printf("(%ld)i:%d\n", pthread_self(), ++(*i));
		if (count >= 20)
		{
			printf("count:%d\n", count);
			void *ret = (void *)i;
			return ret;
		}
		count++;
		sleep(rand() % 3);
	}
}

int main(char *argc, char **argv)
{
	int i = 100;
	int j = 200;
	int k = 300;
	create(tmp, (void *)&i);
	create(tmp, (void *)&j);
	create(tmp, (void *)&k);
	join();
	// void *ret = tmp(&i);
	// printf("ret :%d\n", *(int *)ret);
}
